package cn.wolfcode.designpattern.flyweight;

/**
 * @author Leon
 * @date 2021/2/26
 * 客户端
 */
public class WolfPanClient {

    private String id;
    private User user;
    private WolfPanServer server;

    public WolfPanClient(String id, WolfPanServer server) {
        this.id = id;
        this.server = server;
        server.connect(this);
    }

    public void login(User user) {
        System.out.println("用户："+user.getUsername()+" 登录了...");
        this.user = user;
    }

    public void upload(LocalFile localFile) {
        server.uploadFile(user, localFile);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public WolfPanServer getServer() {
        return server;
    }

    public void setServer(WolfPanServer server) {
        this.server = server;
    }
}


